<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv=X-UA-Compatible content="IE=edge,chrome=1">
    <meta content=always name=referrer>
    <link rel="stylesheet" type="text/css" href="__STATIC__/css/base.css">
    <link rel="stylesheet" type="text/css" href="__STATIC__/css/bg.css">
    <script src="__STATIC__/js/jquery-1.8.2.js"></script>
    <title>个人信息</title>
    <style>
        .fileInput{
            width:100%;
            height:100%;
            position:absolute;
            opacity: 0;
            filter:alpha(opacity=0);
            cursor:pointer;
        }
        #wall{
            top: 0;
            position: absolute;
            left:0;
            opacity: 0;
            width: 100%;
            height: 100%;
        }
    </style>
    <script>
        $(function(){
            $(".first .next").click(
                    function(){
                        var h=$(window).height();
                        $(".wrap-shopinfo .board").css({height:h+"px"});
                        $(".footer").css({display:"block"});
                    }
            )
            $(".sex").click(
                    function(){
                        var h=$(window).height();
                        $(".wrap-shopinfo .board").css({height:h+"px"});
                        $(".sex1").css({display:"block"});
                    }
            )
            $(".cancel").click(
                    function(){
                        $(".wrap-shopinfo  .board").css({height:""});
                        $(".footer").css({display:""});
                    }
            )
            $(".board").click(function () {
                $(this).css({height:0});
                $(".sex1").hide();
            })
            $(".sex1 ul li").click(
                    function(){
                        $(".wrap-shopinfo  .board").css({height:"100%"});
                        $(".sex1").css({display:""});
                        var s=$(this).find("span").text();
                        $.post("{:url('mobile/user_info/edit_sex')}",{'sex':s},function (t) {
                            layer.open({content:t.message,skin:'msg',time:2});

                        })
                        location.reload();
                        $(".sex").find("span").text(s);
                    }
            )
        })
    </script>
</head>
<body>
<div class="wrap-shopinfo">
    <div class="header">
        <p>个人信息</p>
        <img src="__STATIC__/img_user/back.png" class="back" onclick=window.location.href="{:url('mobile/user_info/my_shop_index')}">
    </div>
    <div class="dpset">
        <ul>
            <form action="" method="post"  id="form" >
            <li class="first">
                <h4 class="left" style="line-height: 50px;">个人头像</h4>
                <p class="right">
                    <img {if condition="strstr($arr.avatar,'http')"} src="{$arr.avatar}" {else/} src="/{$arr.avatar}" {/if} class="pic1" onerror="this.src='/static/mobile/img-new/icon1.png'"/>
                <img src="__STATIC__/img_user/next1.png" class="next" >
                </p>
                <div id="wall" >
                    <input type="file"  id="File" name="file" class="fileInput" accept="image/*" />
                </div>
                <input type="hidden" name="id" value="{$arr.id}" />
            </li>
            <li onclick="edit()">
                <h4 class="left">昵称</h4>
                <p class="right"><span id="name">{$arr.nickname}</span><img src="__STATIC__/img_user/next1.png" class="next" ></p>
            </li>
            <li class="sex">
                <h4 class="left">性别</h4>
                <p class="right"><span id="sex">{eq name="arr.sex" value="1"}男{else/}女{/eq}</span><img src="__STATIC__/img_user/next1.png" class="next"></p>
            </li>
            <li class="last" onclick=window.location.href="{:url('mobile/user_info/address_manage')}">
                <h4 class="left">我的收货地址</h4>
                <p class="right"><img src="__STATIC__/img_user/next1.png" class="next" ></p>
            </li>
            <li class="last" onclick="share()">
            </form>
        </ul>
    </div>
    <div class="footer">
        <ul>
            <li><a href="#">相册</a></li>
            <li><a href="#">拍照</a></li>
            <li class="cancel"><a href="#">取消</a></li>
        </ul>
    </div>
    <div class="board"></div>
    <div class="sex1">
        <p>修改性别</p>
        <ul>
            <li class="boy">
                <a href="#">
                    <img src="__STATIC__/img_user/boy.png"><br><span>男</span>
                </a>
            </li>
            <li class="girl">
                <a href="#">
                    <img src="__STATIC__/img_user/girl.png"><br><span>女</span>
                </a>
            </li>
        </ul>
    </div>
</div>

{include file="public/src" /}

<script>
    var index = '';
    $(document).ajaxStart(function(){
        index = layer.open({type: 2,content: '正在上传...'});
    });
    $(document).ajaxComplete(function(){
        layer.close(index);
    });
    $(function(){
        //上传头像
        $('#File').change(function () {
            var id = $('#id').val();
            $('#form').ajaxSubmit({
                url:"{:url('mobile/user_info/upload_avatar')}",
                type:'post',
                dataType:'json',
                enctype: 'multipart/form-data',
                success:function(t){
                    if (t.code == 200){
                        $('.pic1').prop('src','/'+t.message);
                        layer.open({content:'头像上传成功',skin:'msg',time:2});
                    }else{
                        layer.open({content:t.message,skin:'msg',time:2});
                    }
                },
                error: function () {
                    layer.open({content:'网络繁忙,请重试',skin:'msg',time:2});
                }
            });
        })
    });




    function edit(){
        var name=$('#name').text();
        window.location.href="{:url('mobile/user_info/edit_nickname')}?nickname="+name;
    }
</script>
</body>
</html>